<template>
  <section class="page">
    <headerbar>驻村工作</headerbar>

    <!--<div class="banner">
      <img src="../../../../static/images/dangjian/home/workvillage/banner.png" alt="">
    </div>

    <section class="list-icon-btns mgt-2">
      <div class="icon-btns">
        <div @click="goShare('redfriendscircle')" class="item">
          <i class="img"><img src="../../../../static/images/dangjian/zcgz/hdfx.png" alt=""></i>
          <span class="text">互动分享</span>
        </div>
        <div @click="go()" class="item">
          <i class="img"><img src="../../../../static/images/dangjian/zcgz/zcfd.png" alt=""></i>
          <span class="text">驻村辅导</span>
        </div>
        <div @click="goPolicyDocument()" class="item">
          <i class="img"><img src="../../../../static/images/dangjian/zcgz/zcwj.png" alt=""></i>
          <span class="text">政策文件</span>
        </div>
      </div>
    </section>-->

  </section>
</template>

<script>
  import tools from '../../../utils/tools'

  export default {
    name: 'workVillage',
    data () {
      return {
        userInfo: {}
      }
    },
    created () {
      this.userInfo = this.$localStorage.get('userInfo')
      this.go()
    },
    methods: {
      go () {
        let flag = false
        if (this.userInfo.type === '6') {
          this.$router.replace({name: 'tutoringVillage'})
          return
        } else if (this.userInfo.type === '7') {
          this.$router.replace({name: 'tutoringVillageTeacher'})
          return
        } else if (this.userInfo.type === '8') {
          this.$router.replace({name: 'tutoringVillageLeader'})
          this.$store.state.userGroup = {
            groupId: this.userInfo.mainGroupId,
            groupName: this.userInfo.mainGroupName
          }
          return
        }
        this.userInfo.canGroups.map((v) => {
          if (v.userType === '6') {
            flag = true
            this.$router.replace({name: 'tutoringVillage'})
          } else if (v.userType === '7') {
            flag = true
            this.$router.replace({name: 'tutoringVillageTeacher'})
          } else if (v.userType === '8') {
            flag = true
            this.$router.replace({name: 'tutoringVillageLeader'})
            this.$store.state.userGroup = v
          }
        })
        if (!flag) {
          this.showNoRoleAlart()
        }
      },
      showNoRoleAlart () {
        tools.tip('你没有权限访问')
      },
      goShare (name) {
        if (this.getRole()) {
          this.$router.push({path: `/redfriendscircleShare/workVillage`})
        } else {
          this.showNoRoleAlart()
        }
      },
      goPolicyDocument () {
        let id = '1f2c47f8273a43efb0b9dfd2fe554808'
        this.$router.push({path: `/policyDocument/${id}`})
      },
      getRole () {
        let flag = false
        if (this.userInfo.type === '6') {
          flag = true
        } else if (this.userInfo.type === '7') {
          flag = true
        } else if (this.userInfo.type === '8') {
          flag = true
        }
        this.userInfo.canGroups.map((v) => {
          if (v.userType === '6') {
            flag = true
          } else if (v.userType === '7') {
            flag = true
          } else if (v.userType === '8') {
            flag = true
          }
        })
        return flag
      }
    }
  }
</script>

<style lang="scss" scoped>
  @import "@/common/stylus/moon.scss";

  .banner {
    width:100%;
    height:pxToRem(380px);
    background:$theme-color;
    img {
      @include fullImg();
    }
  }
</style>
